//
//  YXReplyLandlordView.m
//  CreditCard
//
//  Created by 杨旭 on 2018/1/20.
//  Copyright © 2018年 杨旭. All rights reserved.
//

#import "YXReplyLandlordView.h"
#import "YXPostModel.h"
@interface YXReplyLandlordView ()
@property (nonatomic ,strong) UIImageView *picImageView;
@property (nonatomic ,strong) UILabel *titleLab;
@property (nonatomic ,strong) UIView *lineView;
@end

@implementation YXReplyLandlordView

- (UIImageView *)picImageView {
    if (!_picImageView) {
        _picImageView = [UIImageView new];
        _picImageView.backgroundColor = [UIColor redColor];
        _picImageView.layer.masksToBounds = YES;
        _picImageView.layer.cornerRadius = 15.0f;
    }
    return _picImageView;
}
- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [UILabel setLabelWithText:@"养卡真的很轻松" fontSize:15 color:color_textTwo];
    }
    return _titleLab;
}
- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = color_lineColor;
    }
    return _lineView;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor py_colorWithHexString:@"#f2f2f2"];
        [self addSubview:self.picImageView];
        [self addSubview:self.titleLab];
        [self addSubview:self.lineView];
    }
    return self;
}

- (void)setModel:(YXPostModel *)model {
    _model = model;
    [_picImageView sd_setImageWithURL:[NSURL URLWithString:_model.portraitImgUrl] placeholderImage:[UIImage imageNamed:@""]];
    _titleLab.text = _model.title;
}


- (void)layoutSubviews {
    [super layoutSubviews];
    YXWeakSelf
    [_picImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mas_left).offset(10);
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.picImageView.mas_right).offset(10);
        make.centerY.equalTo(weakSelf.mas_centerY);
        make.right.equalTo(weakSelf.mas_right).offset(-20);
    }];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mas_left).offset(0);
        make.bottom.equalTo(weakSelf.mas_bottom).offset(0);
        make.size.mas_equalTo(CGSizeMake(kScreenWidth, 1));
    }];
}

@end
